package com.li.configserve.config.mybatis;

import com.li.toolkit.utils.MapUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;

import java.util.Map;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2022/1/17 21:25
 */
public class MapWrapperFactory implements ObjectWrapperFactory {


    @Override
    public boolean hasWrapperFor(Object object) {
        return object instanceof Map;
    }

    @Override
    public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
        return new MapKeyLowerWrapper(metaObject, MapUtils.getMap(object));
    }
}